package com.dddpeter.app.service;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.dddpeter.app.entity.User;
import com.dddpeter.app.object.BussinessService;

/** 
* @ClassName: UserInfoGetService 
* @Description: 用户信息获取服务实现类
* @author Peter Lee
* @date 2014年8月11日 下午2:11:40 
*  
*/
public class UserInfoGetService implements BussinessService {
	private static final Logger LOG = Logger.getLogger(UserInfoGetService.class); 
	User user;
	String jsonStr;
	@Override
	public void init() {
		// TODO Auto-generated method stub

	}

	@Override
	public void service(String serviceName, Map<Object, Object> paramMap) {
		SerializerFeature[] features = {
				SerializerFeature.WriteNullNumberAsZero,
				SerializerFeature.WriteNullStringAsEmpty,
				SerializerFeature.DisableCircularReferenceDetect};
		LOG.info("开始服务：" + serviceName);
		user = (User) paramMap.get("user");
		jsonStr = JSON.toJSONString(user, features);

	}

	@Override
	public Map<Object, Object> output() {
		// TODO Auto-generated method stub
		Map map = new HashMap();
		JSONObject json = JSONObject.parseObject(jsonStr);
		for (Object k : json.keySet()) {
			Object v = json.get(k);
			map.put(k, v);
		}

		return map;
	}

}
